/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.*;
/**
 *
 * @author Tri
 */
public class Client {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try {
//            InetAddress[] addresses = InetAddress.getAllByName(null) 
            InetAddress myhost = InetAddress.getLocalHost();
            System.out.println("Host address :"+myhost.getHostAddress());
            System.out.println("Host Name :"+myhost.getHostName());
            String sentence ,modifiedSentence;
            BufferedReader inFormClient = new BufferedReader(new InputStreamReader(System.in));
            
            Socket clientSocket = new Socket(InetAddress.getLocalHost(), 5000);
            
            BufferedReader inFormServer = new BufferedReader(
                    new InputStreamReader(clientSocket.getInputStream()));
            
            DataOutputStream outToSever = new DataOutputStream(clientSocket.getOutputStream());
            
            sentence = inFormClient.readLine();
            System.out.println("Sent to sever : "+sentence);
            
            outToSever.writeBytes(sentence+'\n');
            modifiedSentence = inFormServer.readLine();
            System.out.println("Sent form server : "+modifiedSentence);
        
        } catch (Exception e) {
        }
    }
}
